<?php
/**
 * Created by PhpStorm.
 * User: 颖inv
 * Date: 2016/10/14
 * Time: 12:42
 */
header('Content-type:text/html;charset=utf-8');
?>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>获取文件后缀</title>
        <style>
            body{background-color: #DADADA;}
            .box{background-color: white; width:300px; height: 120px;}
            h2{text-align: center;}
        </style>
    </head>
    <body>
        <div class="box">
            <?php
            function getFileExt($path){
                $ext=substr($path, strrpos($path,'.')+1);
                return $ext;
            }
            $path='C:\image\apple.jpg';
            $ext=getFileExt($path);
            echo "<h2>获取文件后缀</h2>";
            echo "<p>文件路径：$path </p>";
            echo "<p>文件后缀：$ext </p>";
            ?>
        </div>
    </body>
</html>